package com.atguigu.gmall.file;

import org.csource.fastdfs.*;
import org.springframework.util.ClassUtils;

/**
 * @Author: 孙润达
 * @Date: 2022/1/5 12:04
 */

public class FileUploadDemo {
    public static void main(String[] args) throws Exception {
        /*
        D:\Atguigu\05_Code\gmall\gmall-parent
        \service\service-product\src\main\resources\fdfs_client.conf
        * */
        String path1 = ClassUtils.getDefaultClassLoader().getResource("fdfs_client.conf").getPath();

        //加载配置文件
        ClientGlobal.init(path1);
        //1创建跟踪器
        TrackerClient trackerClient = new TrackerClient();
        //2.连接跟踪器
        TrackerServer connection = trackerClient.getConnection();
        //3.创建服务器的存储节点客户端
        /*
        StorageClient1有两个方法，无参和两参
        * */
        StorageServer storageServer=null;
        StorageClient1 storageClient1 = new StorageClient1(connection, storageServer);

        //上传图片
        String path = storageClient1.upload_file1("D:\\Atguigu\\03_Video\\尚品汇商城\\" +
                "资料\\图片\\华为mate30\\5c427fea652c1db4.jpg", "jpg", null);
        System.out.println("path = " + path);
    }
}
